% function to set defaults for
% ts processing
% In future this need to be changed to a GUI dialogue box
% Any new entry can be made to the structure ProcDef
% However NO ENRTY/FIELD SHOULD BE deleted from ProcDef

%latest date 16.06.2003

function[ProcDef] = SetDefault_h

nband = 1;% Used in MT processing, but no use in geomag tf

ProcDef.ref = 0; % remote reference, keep ref = 1 for rr. 0 otherwise

% Be careful about changing channel number, equations, array etc
% as it is used by many functions
ProcDef.Array    = [4 5 1 2 3 6 7]; % EDI standard PL DO NOT CHANGE
ProcDef.sensor   = [1 2 3 4 5 3 4]; % Ex Ey Hx Hy Hz Hxr Hyr channel number;
%ProcDef.notchdef = [1 1 1 1 1 2 2]; % stite1 & site2 notch used in getspectra.m
												% Also used in rrcorrectts.m as 
												% ProcDef.sensor(find(ProcDef.notchdef==2)) To pack the remote m filed to 
ProcDef.equations = [4 1 2;5 2 1];  % defining bi-variate eqns                  Local spec change here
ProcDef.rreqn = [4 1 2 6 7;5 1 2 6 7]; % eqn for rr processing                  default = [1 1 1 1 1 2 2];
ProcDef.neq = 2; % number of equtions defined
% -------------------------------------------------------------------

ProcDef.PAI = 3.1415926535897; % is it needed ?
ProcDef.MaxVal = 1.0E+6;  % Value(s) to scale SPMatrices
ProcDef.MinVal = 1.0E-6;
ProcDef.ScaleVal = 1.0E+4;
%ProcDef.RadSize = [0.125 0.25 0.5 0.75];   % size of Parzen window
ProcDef.RadSize = [0.1 0.1 0.1 0.1];   % size of Parzen window Feb 22, 2011
ProcDef.RdBd    = [1 1 1 1 1];	% Feb 22, 2011
ProcDef.GMS05.fs = [1 1 1 1 1]; % samplig rate gms05 bands Feb 22, 2011
%selblock =  [128;256;512;1024;2048;4096;4096*2,4096*4]; 

% Settings for EMSLAB data
%   ProcDef.DeltaFreq = [1.0/20]./1024;% Sampling interval in Hz divided by 1024
%   ProcDef.MinFreq      = 1/100000;
%   ProcDef.MaxFreq      = (1/20)/4;
%   ProcDef.TLFreq = logspace(-2,-4,20);
%   mychoice = [4096;4096;4096;4096;4096]; % this overrides the user menu selection 

% Settings for IPM&PPT data
%   ProcDef.DeltaFreq    = 1.0/1024;% Sampling interval in Hz divided by 1024
%   ProcDef.MinFreq      = 1/10000;
%   ProcDef.MaxFreq      = 1/4;
%   ProcDef.TLFreq = logspace(-1,-4,30);
  
%setting for JULIA data 128

%   ProcDef.DeltaFreq    = (1/(5*60))/1024;% Sampling interval in Hz divided by 1024
%   ProcDef.MinFreq      = 1/(10*3600);
%   ProcDef.MaxFreq      = (1/(5*60*2));
%   ProcDef.TLFreq = logspace(-2.8,-4.5,12);
%   mychoice = [128;128;128;128;128]; % this overrides the user menu selection 
%   ProcDef.RadSize = [0.1 0.1 0.1 0.1] * 0.5;   % size of Parzen window Feb 22, 2011
% 
%setting for JULIA data 128

%   ProcDef.DeltaFreq    = (1/(5*60))/1024;% Sampling interval in Hz divided by 1024
%   ProcDef.MinFreq      = 1/(10*3600);
%   ProcDef.MaxFreq      = (1/(5*60*2));
%   ProcDef.TLFreq = logspace(-2.8,-4.2,12);
%   mychoice = [64;64;64;64;64]; % this overrides the user menu selection 
%   ProcDef.RadSize = [0.1 0.1 0.1 0.1] * 0.5;   % size of Parzen window Feb 22, 2011

%setting for CHAMP data (RESAMPLED AT 2 HOURS)
  ProcDef.DeltaFreq    = (1/(120*60))/1024;% Sampling interval in Hz divided by 1024
  mxPeriodHours = 30;
  mnPeriodHours = 5;
  nPeriods = 6;
  ProcDef.MinFreq      = 1/(mxPeriodHours*3600);
  ProcDef.MaxFreq      = (1/(mnPeriodHours*3600));
  ProcDef.TLFreq = logspace(log10(1/(mxPeriodHours*3600)),log10(1/(mnPeriodHours*3600)),nPeriods);
  mychoice = [64;64;64;64;64]*2; % this overrides the user menu selection 
  ProcDef.RadSize = [0.1 0.1 0.1 0.1]*1 ;   % size of Parzen window Feb 22, 2011


ProcDef.block = mychoice(nband); 
ProcDef.annthreshold = 0.6; % ANN slection threshold (applicable to band 4)
ProcDef.DoANN = 0; % 1 ANN selection ON; 0 OFF

ProcDef.Method = 'RB'; %LS - Least Square; RB - Robust M; JK - Jack Knife; CO - Coherencies; CT Coherency Treshold
% Selection of averaging methods
ProcDef.BandAv = 'R'; % R - Robust band averaging P = parzen averaging

ProcDef.CohTr = 0.4;

ProcDef.nband=nband;      % nband comes from invoking program

ProcDef.overlap = 0;  % set to 0 for non overlap of ts

[TLine,TLRad,TLFreq,TBand] = settline_h(ProcDef); % target freq, line & radius for all bands
ProcDef.TLine1  = TLine(TBand==nband);
ProcDef.TLRad1  = TLRad(TBand==nband);
ProcDef.TLRad1(ProcDef.TLRad1<1)=1; % ensures min dof
k=find((ProcDef.TLine1-ProcDef.TLRad1)<0);
ProcDef.TLFreq1 = TLFreq(TBand==nband);
ProcDef.TLFreq1(k)=[]; % This deletes frequencies with less than 4 harmonics to average
ProcDef.nfrq = length(ProcDef.TLine1)-length(k);
ProcDef.len=0; % number of blocks (nfft) to be set lateron by main program
ProcDef.file1=char([1 12]); % Local station name (to be set by main program)
ProcDef.file2=char([1 12]); % Reomte station name ( ,,           ,,        )
ProcDef.WriteEdi=0;   % 1 writes the Output Spectra in edi format